package com.tao.direct;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.utils.RabbitMQUtils;

import java.io.IOException;

/**
 * @ClassName Provider
 * @Author HETAO
 * @Date 2020/5/4 21:54
 */
public class Provider {
    public static void main(String[] args) throws IOException {
        Connection connection = RabbitMQUtils.getConnection();
        Channel channel = connection.createChannel();
        //创建交换机
        channel.exchangeDeclare("logs_direct", "direct", false);
        String key = "error";
        channel.basicPublish("logs_direct", key, null, ("这是基于direct模型发布的基于route key:[ " + key + " ]发送的信息").getBytes());
        RabbitMQUtils.closeConnectionAndChanel(channel, connection);
    }
}
